<!DOCTYPE html>
<html>

	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta name="format-detection" content="telephone=no" />
		<meta charset="utf-8">
		<title>排行</title>
		<link rel="stylesheet" href="__TPL__/team/css/ectouch.css" />

	</head>

	<body>
		<div class="con">
			<div id="loading"><img src="__TPL__/team/images/loading.gif" /></div>
			<div class="cont-pb">
				<div class="goods-info of-hidden ect-tab b-color-f j-goods-info j-ect-tab ts-3">
					<div class="hd j-tab-title tab-title b-color-f of-hidden">
						<ul class="dis-box">
							<li class="box-flex <!--{if $type eq 'best'}-->active<!--{/if}-->"><a href="{:url('category/user_ranking',array('type'=>'best'))}">热门</a></li>
							<li class="box-flex <!--{if $type eq 'new'}-->active<!--{/if}-->"><a href="{:url('category/user_ranking',array('type'=>'new'))}">新品</a></li>
							<li class="box-flex <!--{if $type eq 'hot'}-->active<!--{/if}-->"><a href="{:url('category/user_ranking',array('type'=>'hot'))}">优选</a></li>
						</ul>
					</div>
					<div id="j-tab-con" class="b-color-f m-top1px tab-con ">
						<div class="swiper-wrapper">
							<section class="swiper-slide">
								<ul class="user-ranking-box" id="j-product-box">
								
									<script id="j-product" type="text/html">
									<%each list as vo %>
									<li class="dis-box flow-checkout-list-box b-color-f padding-all position-rel">
										<a class="product-div-link" href="<%vo.url%>"></a>
										<div class="flow-checkout-list-left">
											<div class="flow-checkout-list-left-img position-rel">
												<img class="img" src="<%vo.goods_img%>" />
												<%if vo.key%>
												<img class="user-rank-list position-abo" src="__TPL__/team/images/icon/rank-<%vo.key%>.png" />
												<%/if%>
											</div>
										</div>
										<div class="box-flex">
											<h4 class="font-06 col-3 onelist-hidden"><%vo.goods_name%></h4>
											<p class="col-7 font-03 m-top02"><%vo.limit_num%>人参团</p>
											<div class="dis-box user-rank-cont">
												<div class="box-flex ec-color"><%vo.shop_price%></div>
												<div class="box-flex">
													<div class="dis-box user-ranking-btn font-05">
														<div class="box-flex"><span class="ec-tag sum-btn num-btn"><%vo.team_num%>人团</span></div>
														<div class="box-flex"><span class="b-tag ec-white cont-btn">去开团</span></div>
													</div>
												</div>
											</div>
										</div>
									</li>
									<%/each%>
									</script>
									
								</ul>
							</section>
							
						</div>
					</div>
				</div>
				{if $is_show neq 1}
				<div class="footer-cont"><span><img src='__TPL__/team/images/loading1.gif'>正在加载……</span></div>
				{/if}
			</div>
			{if $is_show eq 1}
			<div class="no-div-message">
				<i class="iconfont icon-biaoqingleiben"></i>
				<p>亲，此处没有内容～！</p>
			</div>
			{/if}
		</div>
		<!--footer-nav-->
		<footer class="footer-nav dis-box">
			<a href="{:url('index/index')}" class="box-flex nav-list ">
				<i class="nav-box i-home"></i><span>首页</span>
			</a>
			<a href="{:url('category/top_all')}" class="box-flex nav-list">
				<i class="nav-box i-cate"></i><span>分类</span>
			</a>
			<a href="{:url('category/user_ranking')}" class="box-flex nav-list active">
				<i class="nav-box i-ranking"></i><span>排行</span>
			</a>
			<a href="{:url('flow/cart')}" class="box-flex position-rel nav-list">
				<i class="nav-box i-flow"></i><span>购物车</span>
				<em class="position-abo ect-num-tag">10</em>
			</a>
			<a href="{:url('user/index')}" class="box-flex nav-list">
				<i class="nav-box i-user"></i><span>用户中心</span>
			</a>
		</footer>
		<!--引用js-->
		<script type="text/javascript" src="__TPL__/team/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="__TPL__/team/js/swiper.min.js"></script>
		<script type="text/javascript" src="__TPL__/team/js/ectouch.js"></script>
		<script type="text/javascript" src="__TPL__/statics/js/echo.min.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/template.js"></script>
		<script type="text/javascript">			
			var url = '{:url('category/user_ranking', array( 'type'=>$this->_var['type']))}';
			var total = 0;
			
			var page = {$page};

			page = (page === null) ? 1:parseInt(page);
			
			get_data(page);
			localData.set('page', page);
			if(page == 1){
				localData.set('page_min', 1);
				localData.set('page_max', 1);
			}
			if(page > 1){
				localData.set('page_min', page);
				localData.set('page_max', page);
			}
			var minPage = localData.get('page_max');
			var maxPage = localData.get('page_max');
			minPage = (minPage === null) ? 1:parseInt(minPage);
			maxPage = (maxPage === null) ? 1:parseInt(maxPage);

			$(window).scroll(function () {
				var scrollTop = $(this).scrollTop();
				var scrollHeight = $(document).height();
				var windowHeight = $(this).height();
				
				// 下拉
				if (scrollTop + windowHeight == scrollHeight) {
					if(page >= maxPage){
						$.ajax({
							type : "post",
							url : url,
							data : {
							    page : page+1,
							},
							dataType: 'json',
							async : false,
							success : function(data){
								//template.config('openTag', '<%');
								//template.config('closeTag', '%>');
								var html = template('j-product', data);
								$('#j-product-box').append(html);
								//rug
								if(!isEmpty(data.list)){
									page++;
									localData.set('page', page);
									if(page > maxPage){
										localData.set('page_max', page);
									}
								}
							}
						});
					}
				}
				// 上拉
				if(scrollTop == 0 && minPage > 1){
					$.ajax({
						type : "post",
						url : url,
						data : 'page=' + (page - 1),
						dataType: 'json',
						async : false,
						success : function(data){
							//template.config('openTag', '<%');
							//template.config('closeTag', '%>');
							var html = template('j-product', data);
							$('#j-product-box').prepend(html);
							page--;
							localData.set('page', page);
							if(page < minPage){
								localData.set('page_min', page);
							}
						}
					});
				}
			});

			function get_data(page){
				$.ajax({
					type : "post",
					url : url,
					data : {
						page : 1,
					},
					dataType: 'json',
					async : false,
					success : function(data){
						template.config('openTag', '<%');
                        template.config('closeTag', '%>');
						var html = template('j-product', data);
						//alert(html);
						$('#j-product-box').append(html);
					}
				});
			}
			/*
			   * 检测对象是否是空对象(不包含任何可读属性)。
			   * 方法既检测对象本身的属性，也检测从原型继承的属性(因此没有使hasOwnProperty)。
			   */
		   function isEmpty(obj) {
			   for (var name in obj) {
				   return false;
			   }
			   return true;
		   }
		  echo.init();
	
			$(function($) {
				$(".j-detail-close").click(function(){
					$(".raise-search-cont").addClass("active");
				})
				//nav
				window.onload = function() {
					var $li = $('.raise-cate-nav li');
					var $ul = $('.raise-content ul');

					$li.click(function() {
						var $this = $(this);
						var $t = $this.index();
						$li.removeClass();
						$this.addClass('current');
						$ul.css('display', 'none');
						$ul.eq($t).css('display', 'block');
					})
				}
				$(".j-text-all,.raise-bg-box").click(function() {
					$(".raise-content").addClass("active");
					$(".raise-bg-box").addClass("active");
					$(".category-header-box").addClass("active");
				});
				$(".raise-cate-nav li").click(function() {
					$(".raise-content").removeClass("active");
					$(".raise-bg-box").removeClass("active");
					$(".category-header-box").removeClass("active");
				});
				//下拉加载更多
				 $(window).scroll(function() {
                if ($(document).scrollTop() > $(window).height() < $(document).height() - $(window).height()) {
                       $(".footer-cont").html("<span><img src='__TPL__/team/images/loading1.gif'>正在加载……</span>")
                }
                if ($(document).scrollTop() >= $(document).height() - $(window).height()) {

			        $(".footer-cont").html("<span>没有更多了</span>")
			     
                }
            });
			});
			
	
		</script>
		<script>
			/*切换*/
			/*var tabsSwiper = new Swiper('#j-tab-con', {
				speed: 100,
				noSwiping: true,
				autoHeight: true,
				onSlideChangeStart: function() {
					$(".j-tab-title .active").removeClass('active')
					$(".j-tab-title li").eq(tabsSwiper.activeIndex).addClass('active')
				}
			})
			$(".j-tab-title li").on('touchstart mousedown', function(e) {
				e.preventDefault()
				$(".j-tab-title .active").removeClass('active')
				$(this).addClass('active')
				tabsSwiper.slideTo($(this).index())
			})
			$(".j-tab-title li").click(function(e) {
					e.preventDefault()
				})*/
				/*店铺信息商品滚动*/
			/*var swiper = new Swiper('.j-g-s-p-con', {
				scrollbarHide: true,
				slidesPerView: 'auto',
				centeredSlides: false,
				grabCursor: true
			});*/
		</script>
	</body>

</html>